package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.domain.SuccessCode;
import com.atguigu.jxc.entity.OverflowList;
import com.atguigu.jxc.service.OverFlowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/overflowListGoods")
public class OverFlowController {
    @Autowired
    private OverFlowService overFlowService;
    //http://localhost:8080/overflowListGoods/save?overflowNumber=BY1605767033015
    @PostMapping("/save")
    public ServiceVO save(OverflowList overflowList, String overflowListGoodsStr){
        OverflowList Overflow= new OverflowList();
        String overflowNumber = Overflow.getOverflowNumber();
        this.overFlowService.save(overflowList,overflowListGoodsStr,overflowNumber);
        return new ServiceVO<>(SuccessCode.SUCCESS_CODE, SuccessCode.SUCCESS_MESS);
    }
    //    http://localhost:8080/overflowListGoods/list
    @PostMapping("/list")
    public Map<String, Object> save(String sTime, String eTime) {
        return this.overFlowService.list(sTime,eTime);
    }
    //http://localhost:8080/overflowListGoods/goodsList
    @PostMapping("/goodsList")
    public Map<Object, Object> getListById(Integer overflowListId) {
        return this.overFlowService.getListById(overflowListId);
    }
}
